<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">

        <router-view></router-view>

        <ul>
            <li>
                <router-link to="/home">首页</router-link>
            </li>
            <li>
                <router-link to="/login">登录</router-link>
            </li>
        </ul>

       
    </div>
    <template id="login">
        <div>
            <router-link to="/duanxin">短信验证登陆</router-link>
            <router-link to="/account">账户密码登陆</router-link>

            <router-view></router-view>
        </div>
    </template>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script src="./node_modules/vue-router/dist/vue-router.js"></script>
    
    <script>
        let home = {
            template: "<div>home</div>"
        }

        let login = {
            template: "#login"
        }

        let duanxinLogin = {
            template: "<div>这是短信登录</div>"
        }
        let accountLogin = {
            template: "<div>这是账户名密码登录</div>"
        }

        const routes = [
            {
                path: "/home",
                component: home
            },
            {
                path: "/login",
                component: login,
                children: [
                    {
                        // 没有加 /  那么这个路径  ==== /login/duanxin
                        path: "/duanxin",
                        // path: "duanxin", ==== /login/duanxin
                        component: duanxinLogin
                    },
                    {
                        // /login/account
                        path: "/account",
                        // path: "account", ==== /login/account
                        component: accountLogin
                    }
                ]
            }
        ]

        const router = new VueRouter({
            routes
        })

        const app = new Vue({
            el: "#app",
            router
        })
    </script>
</body>
</html>